<?php
require_once("database.php");
class xl_thongbao extends database
{
	function danh_sach($vi_tri, $so_luong)
	{
		$vi_tri = intval($vi_tri);
		$so_luong = intval($so_luong);
		$sql = "select * from thongbao limit $vi_tri, $so_luong";
		$this->setQuery($sql);
		return $this->loadAllRow();
	}
	function so_luong()
	{
		$sql = "select count(*) from thongbao";
		$this->setQuery($sql);
		return $this->loadResult();
	}
	function xem($ID_ThongBao)
	{
		$ID_ThongBao = intval($ID_ThongBao);

		$sql = "select * from thongbao where ID_ThongBao = '$ID_ThongBao'";
		$this->setQuery($sql);
		return $this->loadRow();
	}
	function xoa($ID_ThongBao)
	{
		$ID_ThongBao = intval($ID_ThongBao);

		$sql = "delete from thongbao where ID_ThongBao = '$ID_ThongBao'";
		$this->setQuery($sql);
		$this->query();
	}
	function them($TieuDe, $NoiDung, $ID_ToChuc, $NgayThongBao)
	{
		$TieuDe = addslashes($TieuDe);
		$NoiDung = addslashes($NoiDung);
		$ID_ToChuc = intval($ID_ToChuc);

		$sql = "INSERT INTO thongbao(TieuDe,NoiDung,ID_ToChuc,NgayThongBao) VALUES ('$TieuDe','$NoiDung','$ID_ToChuc','$NgayThongBao')";
		$this->setQuery($sql);
		return $this->query();
	}
	function cap_nhat($ID_ThongBao, $TieuDe, $NoiDung, $ID_ToChuc, $NgayThongBao)
	{
		$ID_ThongBao = intval($ID_ThongBao);
		$TieuDe = addslashes($TieuDe);
		$NoiDung = addslashes($NoiDung);
		$ID_ToChuc = intval($ID_ToChuc);

		$sql ="UPDATE thongbao SET TieuDe= '$TieuDe', NoiDung= '$NoiDung', ID_ToChuc= '$ID_ToChuc', NgayThongBao= '$NgayThongBao' WHERE ID_ThongBao = '$ID_ThongBao'";
		$this->setQuery($sql);
		return $this->query();
	}
	
 }
?>